package cn.edu.scau.cmi.ZengLinghong.chapter04;

public class PrimeNumber {

	public static void main(String[] args) {
		final int All_Prime_Number = 50;
		final int Perline_Prime_Number = 10;
		final int Max_number = 230;
		int count = 0, number = 2;
		int[] prime = new int[All_Prime_Number];
		boolean[] vis = new boolean[Max_number];
		while(count<All_Prime_Number) {
			if(!vis[number]) prime[count++]=number;
			for(int i=0; i<count&&number*prime[i]<Max_number; i++) {
				vis[number*prime[i]] = true;
				if(number%prime[i]==0) break;
			}
			number++;
		}
		for(int i=0; i<All_Prime_Number; i++) {
			if(i%Perline_Prime_Number==0) System.out.println();
			System.out.printf("%3d ",prime[i]);
		}
	}

}
